Ccay.Module.define("Ccay.task.Export2", function(page, $S) {
			/**
			 * Grid初始化
			 */
			page.ready = function() {
				$("#ccay-operate").ccayToolbar({
							items : [{
								type : "imgBtn",
								icon : "search",
								text : "ccay.common.button.search",
								css : "default", // 回车搜索的按钮的class
								attr : {
									id : "btnSearch"
								}
							}, {
								type : "imgBtn",
								icon : "reset",
								text : "ccay.common.button.reset",
								css : "reset",
								attr : {
									id : "reset"
								}
							}]
						});
				var attr1Title=true,attr2Title=true,attr3Title=true,attr4Title=true,attr5Title=true;
				
				var gridOptions = {
					height : 300,
					percentWidth : true,
					wrap : true,
					// 设置igrid缓存数据
					cacheData : true,
					// 设置缓存key值
					cacheKey : ["taskId"],
					// 分组显示
					rowRender : "group",
					rowRenderOp : {
						simpleSort : true,
						spareFields : ["exportDate", "moduleName", "exportFlag"]
					},
					customSetting: true,
					// 列设置
					columns : [
						{
						field : 'owner',
						header : "ccay.common.label.operationPersion",
						cssName : "center",
						width : "6%",
						content : "${#showUserInfo(owner,data)}"
					},{
						field : 'tmpName',
						header : "ccay.async.label.taskExportFileName",
						cssName : "left",
						width : "10%"
					}, {
						field : 'moduleName',
						header : "ccay.async.label.taskExportCatalogName",
						cssName : "left",
						width : "5%"
					}, {
						field : 'exportFlag',
						header : "ccay.async.label.taskExportStatus",
						cssName : "center",
						content : "${#exportFlagRenderer(data)}",
						width : "5%",
						getGroupValue : function(value, record) { // 渲染分组操作的组名
							if (value == "0") {
								return $i18n("ccay.common.message.waiting");
							} else if (value == "1") {
								return $i18n("ccay.common.message.inProcess");
							} else if (value == "2") {
								return $i18n("ccay.common.message.succeed");
							} else if (value == "3") {
								return $i18n("ccay.common.message.failed");
							} else if (value == "4") {
								return $i18n("ccay.common.message.syncFailed");
							}
							return "";
						}
					}, {
						field : 'fileSize',
						hidden : true,
						header : "ccay.async.label.taskExportFileSize",
						cssName : "right",
						width : "5%",
						content : "${#fileSizeRender(data)}"
					}, {
						field : 'records',
						hidden : true,
						header : "ccay.async.label.taskExportRecords",
						type : "int",
						cssName : "right",
						width : "5%"
					}, {
						field : 'totalTime',
						hidden : true,
						header : "ccay.task.label.importConsumeTime",
						type : "int",
						cssName : "right",
						width : "8%"
					}, {
						field : 'exportDate',
						width : "6%",
						group : true,
						header : "ccay.task.label.importCreatedTime",
						cssName : "center",
						content : "${#thisToDateBefore(data.exportDate)}",
						getGroupValue : function(value, record) {// 渲染分组操作的组名
							return value.toDate().getUTCTime().format();
						}
					}, {
						field : 'runStartTime',
						hidden : true,
						width : "10%",
						header : "ccay.task.label.importRunStartTime",
						cssName : "center",
						content : "${#thisToDateBefore(data.runStartTime)}"
					}],
					// 设置igrid的ajax请求参数，url属性获取数据源的链接地址
					ajax : {
						url : 'services/ccay/task/export/list/page/monitor/{0}/{1}'
					},
					// Grid操作设置
					operation : {
						search : {
							// 查询按钮id选择器
							btn : '#btnSearch',
							// 查询条件区域id选择器
							panel : '#exportCondForm',
							// 查询请求地址
							url : 'services/ccay/task/export/list/page/monitor/{0}/{1}'
						}
					}
				}
				// 初始化Grid
				$S("#taskExportGrid").igrid(gridOptions);
			};

			/** grid删除按钮 */
			page.del = function() {
				var grid = "#taskExportGrid";
				var records = $(grid).manager().getSelectedRecords();
				var url = "services/ccay/task/export/d/list";
				if (records.length > 0) {
					Ccay.UI.confirm("ccay.common.message.confdel", function(result) {
								if (result) {
									Ccay.doPut(url, records, function() {
												// 调用刷新grid的方法
												$(grid).manager().reload(true, true);
											});
								}
							});
				} else {
					Ccay.UI.showMessage("ccay.common.message.selectedRecords", "warn");
				}

			};

			page.listExportFlag = function() {
				return [{
					value : 0,
					text : $i18n("ccay.common.message.waiting")
				}, {
					value : 1,
					text : $i18n("ccay.common.message.inProcess")
				}, {
					value : 2,
					text : $i18n("ccay.common.message.succeed")
				}, {
					value : 3,
					text : $i18n("ccay.common.message.failed")
				}];
			};

			fileSizeRender = function(data) {
				var fSize = data.fileSize;
				if (!fSize)
					return "";
				return Ccay.Format.toFileSize(fSize);
			};

			// 对时间进行格式化处理
			thisToDateBefore = function(data) {
				return Ccay.Format.toDateBefore(data && data.toDate().getUTCTime());
			};

			/**
			 * 用户id
			 */
			function userId2Account(value, record, columnObj, grid, colNo, rowNo) {
				return "<a title={0} class='init PersonInfo' id='userAccount'  scope='intranet'>{1}</a>".formatValue(value, value);
			}

			// 设置任务状态 (0:Pending ,1:Run , 2:Finish ,3:Restart,4: Failed )
			exportFlagRenderer = function(record) {
				var dis = "";
				var value = record.exportFlag;
				if (value == "0") {
					dis = $i18n("ccay.common.message.waiting");
				} else if (value == "1") {
					dis = $i18n("ccay.common.message.inProcess");
				} else if (value == "2") {
					var succeedShow = $i18n("ccay.common.message.succeed");
					var succeedSize = "";
					if (record.fileSize) {
						succeedSize = Ccay.Format.toFileSize(record.fileSize);
					}
					var succeedTitle = $i18n("ccay.async.label.taskExportFileSize") + ":" + succeedSize + "\n" + $i18n("ccay.async.label.taskExportRecords") + ":" + record.records;
					dis = "<div title='"+succeedTitle+"' ><font>"+succeedShow+"</font></div>";
				} else if (value == "3") {
					dis = $i18n("ccay.common.message.failed");
					var msg = record.fileName;
					if (msg != null) {
						return setShowError(msg, dis);
					}
				} else if (value == "4") {
					dis = $i18n("ccay.common.message.syncFailed");
					dis = "<font color=\"red\">"+dis+"</font>";
				}
				return dis;
			};

			setShowError = function(msg, dis) {
				msg = msg.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/'/g, '&acute;').replace(/"/g, '&quot;').replace(/(^\s*)|(\s*$)/g, "").replace(/\n/g, "");
				return "<div title='" + $i18n("ccay.integration.label.processError") + "' ><a style='cursor:pointer' onclick=\"Ccay.UI.showMessage('" + msg + "','error')\"><font color=\"red\" style='text-decoration: underline'>" + dis + "</font></a><a class='ccay-icon warning' onclick=\"Ccay.UI.showMessage('" + msg + "','error')\"></a></div>";
			};
			tmpNamedownLoadRenderer = function(record) {
				var url = "";
				if (record.guid != null && record.exportFlag == 2) {
					url = "<a href='servlet/iexcelexport?reportName={0}&guid={1}' title='" + $i18n("ccay.edm.label.downloadFile") + "' >{2}</a>".formatURI(record.tmpName, record.guid, record.fileName);
				} else if (record.guid == null && record.exportFlag == 2 && record.fileName != null) {
					url = "<a href='servlet/download?dlType=Excel&excelId=" + record.taskId + "&execFlag=EXP' title='" + $i18n("ccay.edm.label.downloadFile") + "' >" + record.tmpName + "</a>";
				}
				return url;
			};
			
			//人员信息点击查看明细的渲染
			showUserInfo = function(value,data){
				return Ccay.UI.button(data.owner? data.owner :"","Ccay.Component.popUserInfo('{0}')".formatValue(data.owner),"","link");
			};

		});
